package cn.itcast.crm.dao.base;



import java.util.List;














import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;


import org.springframework.data.jpa.repository.Query;

import cn.itcast.crm.domain.Customer;

public interface ICustomerDAO extends JpaRepository<Customer,Integer>,JpaSpecificationExecutor<Customer>{
	
	public List<Customer> findByFixedAreaId(String fixedAreaId);
    public List<Customer> findByFixedAreaIdIsNull();
    @Query("update Customer set fixedAreaId=? where id=?")
    @Modifying
	public void updateFixedAreaId( String fixedAreaId,Integer id);
    @Query("update Customer set fixedAreaId=null where fixedAreaId=?")
    @Modifying
	public void clearFixedAreaId(String fixedAreaId);
    
	public Customer findByTelephone(String telephone);
	@Query("update Customer set type=1 where telephone=?")
	@Modifying
	public void updatetype(String telephone);
	//用户登陆
	public Customer findByTelephoneAndPassword(String telephone, String password);
	//根据地址查询
	@Query("select fixedAreaId from Customer where address=?")
	public String findFixedAreaIdByAddress(String address);

}
